﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.BLL;
using Com.CMS263.PO;

namespace Com.CMS263.Web.manage.ManagerCategory
{
    public partial class Category_action : System.Web.UI.Page
    {

        CategoryBLL cateBll = new CategoryBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = 0;
            string op = Request["op"];
            if (!string.IsNullOrEmpty(Request["id"]))
            {
                id = int.Parse(Request["id"]);
            }

            if (op.Equals("delCatetory"))
            {
                cateBll.entity = (Category)cateBll.FindModelById("Category", id);
                if (cateBll.Delete())
                {
                    Response.Write("ok");
                }
                else
                {
                    Response.Write("no");
                }
            }
            else if (op.Equals("Valid"))
            {
                cateBll.entity = (Category)cateBll.FindModelById("Category", id);
                var bools = (cateBll.entity.IsShow) ? false : true;
                cateBll.entity.IsShow = bools;
                cateBll.UpDate();
                Response.Write((bools) ? "yes" : "no");
            }
        }
    }
}
